import Base from "../Base.js";
import adminsApi from "../../api/admins.js";
export default class extends Base {
    constructor(props) {
        super(props);
    }
    mounted() {

    }
    handle() {

    }
    render() {
        this.el.html(`
        <table id="orders" lay-filter="orders"></table>
        `);
        this.reRender();
    }
    reRender() {
        console.log(1);
        layui.table.render({
            elem: '#orders'
            , method: "get"
            , url: '/api/orders' //数据接口
            , headers: { Authorization: `Bearer ${adminsApi.getToken()}` }
            , page: true //开启分页
            , limits: [5, 10, 15, 20]
            , parseData: function (res) {
                let data = res;
                console.log(data);
            }
            , cols: [[ //表头
                { field: '_id', title: 'ID', sort: true, fixed: 'left' }
                , { field: 'schedulesId', title: '电影', templet: '<div>{{d.schedulesId.movieId.cname}}</div>' }
                , { field: 'schedulesId', title: '影院', sort: true, templet: '<div>{{d.schedulesId.cinemasId.name}}</div>' }
                , { field: 'schedulesId', title: '放映厅', sort: true, templet: '<div>{{d.schedulesId.theaterId.name}}</div>' }
                , { field: 'schedulesId', title: '放映时间', sort: true, templet: '<div>{{d.schedulesId.showTime}}</div>' }
                , { field: 'seats', title: '座位', sort: true, templet: `<div>{{d.seats}}</div>` }
                , { field: 'schedulesId', title: '价格', sort: true, templet: '<div>{{d.schedulesId.price}}</div>' }
                , { field: 'time', title: '购买时间', sort: true, }
                , { field: 'usersId', title: '购买用户', sort: true, templet: '<div>{{d.usersId.userName}}</div>' }
            ]],
        });
    }
}